/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.util.TimerTask;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author Monster
 */
    public class Animation extends TimerTask {

        private Sprite sprite;
        private int nFrame;

        public Animation(Sprite b,int n) {
            this.sprite=b;
            this.nFrame=n;
        }

        public void run() {
            if (this.sprite.getFrame() != this.nFrame-1) {
                this.sprite.nextFrame();
            } else {
                this.sprite.setVisible(false);
                this.cancel();
            }
        }
    }